<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><title>Class: ProsperAPIClient</title><link type="text/css" href=".././rdoc-style.css" rel="stylesheet" media="screen"/><script type="text/javascript">
// Allison template
// Copyright 2007, 2008 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file.

var href_base = '.././rdoc-style.css'.replace(/(.*\/).*/, '$1'); // inline js is good for something  

function $(id) {
    if (document.getElementById)
      elem = document.getElementById(id);
    else if ( document.all )
      elem = eval("document.all." + id);
    else
      return false;
    return elem;
}

  function toggle(id) {
    elem = $(id);
    elemStyle = elem.style;   
    if (elemStyle.display == "block") {
      elemStyle.display = "none"
    } else {
      elemStyle.display = "block"
    }
    return true;
  }

  function toggleText(id) {
    elem = $(id)
    if (m = elem.innerHTML.match(/(Hide)(.*)/)) {
      elem.innerHTML = "Show" + m[2];
    } else if (m = elem.innerHTML.match(/(Show)(.*)/)) {
      elem.innerHTML = "Hide" + m[2];
    }
    return true;
  }

function span(s, klass) {
  return '<span class="' + klass + '">' + s + '</span>';
}
  
function highlightSymbols() {
  pres = document.getElementsByTagName('pre');
  for(var i = 0; i < pres.length; i++) {
    pre = pres[i];
    spans = pre.getElementsByTagName('span');
    for(var k = 0; k < spans.length; k++) {
      span = spans[k];
      if (span.className.match(/ruby-identifier/)) {
        if (span.innerHTML.match(/^:/)) {
          span.className += " ruby-symbol";
        }
      }
    }
  }
}

 function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe() {
    var even = true;
    var color = "#e4ebed";
    var tables = document.getElementsByTagName('table');
    if (tables.length == 0) { return; }
    for (var h = 0; h < tables.length; h++) {
        var trs = tables[h].getElementsByTagName("tr");
        for (var i = 0; i < trs.length; i++) {
          var tds = trs[i].getElementsByTagName("td");
            for (var j = 0; j < tds.length; j++) {       
              if (hasClass(tds[j]) != "first") {                
              var mytd = tds[j];
              if (even) {
                mytd.style.backgroundColor = color;
              }         
            }
          }
          even =  ! even;
      }
    }
  }
  
function ajaxGet(url) {
  url = (href_base + url).replace('/./', '/')
  var req = false;

  if (window.ActiveXObject) {
    try {
      // stupid hack because IE7 disables local Ajax with the native xmlhttprequest object
      // for security purposes. Yet ActiveX still works. Thanks, Microsoft. I hate you. Die.
      req = new ActiveXObject("MSXML2.XMLHTTP.3.0");
    } catch (e) {
      try {
        /* IE 6 and maybe 5, don't know, don't care */
        req = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          req = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          req = false;
        }
      }
    }
  }
    
  /* real browsers */
  if (!req && window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } 
  
  if (req) {
    req.open('GET', url, false);
    req.send(null);
    return req.responseText;
  } else {
    return "Ajax error";  
  }
}


function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
	  elm.addEventListener(evType, fn, useCapture);  
  	return true;
	} else if (elm.attachEvent) {
  	var r = elm.attachEvent('on' + evType, fn);  
	  return r;  
	} else {
  	elm['on' + evType] = fn;
	}
}

function insertIndices() {
  pages = ["class", "file", "method"]
  for (x in pages) { 
    $(pages[x]).innerHTML += ajaxGet('fr_' + pages[x] + '_index.html').replace(/(href=")/g, '$1' + href_base);
  }
  /* mouseoverify method links */
  links = $('method').getElementsByTagName('a');
  for (var x = 0; x < links.length; x++) {
    if (m = links[x].innerHTML.match(/(.*)\s\((.*)\)/)) {
      links[x].innerHTML = m[1] + '<br>';
      links[x].title = m[2];
    }
  }
  /* this is stupid */
  $('class').style.display = "block";
  $('file').style.display = "block";
  
  /* has to be here because IE7 does not guarantee the onLoad callback order */
  abbreviateIndicesInner(["class", "file"], 25, "a");
  /* same, linkTitle() depends on the class link list */
  linkTitle();
}

function abbreviateIndices() {
  var ids = ["defined_in", "child_of", "includes", "requires", "method", "methods"];
  abbreviateIndicesInner(ids, 25, 'a');
  abbreviateIndicesInner(ids, 25, 'span');
}

function abbreviateIndicesInner(indices, amount, tag) {
  for (var x = 0; x < indices.length; x++) { 
    var the_index = $(indices[x]);
    if (the_index) {
      links = the_index.getElementsByTagName(tag);
      for (var y = 0; y < links.length; y++) {
        var link = links[y];
        if (link.getElementsByTagName('span').length == 0 && link.getElementsByTagName('a').length == 0) {
          // avoid nesting
          link.innerHTML = link.innerHTML.replace(/<br>|\n/gi, '');
          link.title = link.innerHTML;
          link.innerHTML = abbreviate(link.innerHTML, amount) + '<br>';
        }
      }
    }
  }
}

function linkTitle() {
  
  /* grab the correct title element from the index */
  var index_page = ajaxGet('index.html');
  title_text = index_page.match(/<title>(.*)<\/title>/m)[1];
  document.title = title_text + " - " + document.title;
  var p = $('header').getElementsByTagName('p')[0]
  if (p.innerHTML.match(/^\s*$/)) {
    p.innerHTML = title_text;
  } else {
    p.innerHTML = title_text + ": " + p.innerHTML;
  }
  
  /* set the link properly */
  title_link = index_page.match(/<a\s+href="(.*?)"/)[1];
  var element = $('title');
  var item_type = "";
  var item_name = "";
  if (m = element.innerHTML.match(/(Class:|Module:|File:)\s*(.*)/)) {
    item_type = m[1];
    item_name = m[2];
  } else {
    item_name = element.innerHTML;
  }
  element.innerHTML = '<a href="' + href_base + title_link + '">' + item_type + " " + abbreviate(item_name, 45) + '</a>';
  element.getElementsByTagName('a')[0].title = item_name
  
  /* breadcrumb navigation */
  items = item_name.split("::");
  items_new = item_name.split("::");
  file_links = $('class').getElementsByTagName('a');
  for (var x = 0; x < items.length - 1; x++ ){
    var item = items[x];
    link = ("/classes/" + items.slice(0,x).join("/") + "/" + item + ".html").replace('//', '/');
    regex = new RegExp(RegExp.escape(link) + '$');
    for (var y = 0; y < file_links.length; y++) {
      if (file_links[y].href.match(regex)) {
         items_new[x] = '<a href="' + href_base + link + '">' + item + '</a>';
         break;
      }
    }  
  }
  $('item_name').innerHTML = item_type + ' ' + items_new.join(" :: ");
}

function abbreviate(s, size) {
  while (s.length > size) {
    var old_s = s;
    s = s.replace(/\s|\n/mg, '');
    s = s.replace(/([A-Z])[a-z]+/m, '$1');
    if (!s || old_s == s) {
      return "..." + s.substring(s.length - size, s.length);
    }
  }
  return s;
}

function disableSubmit(event) {
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if (keyCode == 13) {
    return false;
  } else {
    return true;
  }
}
  
function filterList(id, s, event) {
  
  /* some weak escaping */
  s = s.replace(/[^\w\d\.\_\-\/\:\=\[\]\?\!]/g, '');
  s = RegExp.escape(s);
  
  var show_all = false;
  if (s.match(/^\s*$/)) {
    show_all = true;
  }
  
  links = $(id).getElementsByTagName('a')
  regex = new RegExp(s, 'i');
  
  for (var x = 0; x < links.length; x++) {
    var link = links[x];
    if (show_all) {
      link.style.display = 'inline';
    } else {
       if (link.innerHTML.match(regex)) {        
         link.style.display = 'inline';
       } else {
         link.style.display = 'none';
       }
    }
  }
  return true;
}

RegExp.escape = function(text) {
  if (!arguments.callee.sRE) {
    var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'];
    arguments.callee.sRE = new RegExp(
      '(\\' + specials.join('|\\') + ')', 'g'
    );
  }
  return text.replace(arguments.callee.sRE, '\\$1');
}

function hacks() {
  // show the spacer if necessary, 
  divs = document.getElementsByTagName('div');
  for(var x = 0; x < divs.length; x++) {
    if (divs[x].className && divs[x].className.match(/top/)) {
      document.getElementById('spacer').style.display = 'block';
    }
  }
  // remove extra colons from tables
  tds = document.getElementsByTagName('td');
  for(var x = 0; x < tds.length; x++) {
    str = tds[x].innerHTML
    if (str.charAt(str.length - 1) == ":") {
      tds[x].innerHTML = str.slice(0, str.length - 1)
    }
  }
}

addEvent(window, 'load', insertIndices, false);
addEvent(window, 'load', abbreviateIndices, false);
addEvent(window, 'load', stripe, false);
addEvent(window, 'load', highlightSymbols, false);
addEvent(window, 'load', hacks, false);
</script></head><body><div id="container"><div class="curve" id="preheader_curve_0"></div><div class="curve" id="preheader_curve_1"></div><div class="curve" id="preheader_curve_2"></div><div class="curve" id="preheader_curve_3"></div><div class="curve" id="preheader_curve_4"></div><div class="curve" id="preheader_curve_5"></div><div id="header"><p>
</p><span><h1 id="title">
Class: ProsperAPIClient
</h1></span></div><div class="clear"></div><div id="left">
<div class="navigation darker top" id="child_of"><h3>Child of</h3><span>

Object
</span></div>

<div class="navigation darker top" id="defined_in"><h3>Defined in</h3>

<a href="../files/app/models/prosper_api_client_rb.html">app/models/prosper_api_client.rb</a>

</div>



<div class="navigation top" id="methods"><h3>Methods</h3>


<a href='#M000035'>
describe<br/>
</a>




<a href='#M000028'>
describe<br/>
</a>




<a href='#M000031'>
fetch_rate_table<br/>
</a>




<a href='#M000026'>
login<br/>
</a>




<a href='#M000033'>
login<br/>
</a>




<a href='#M000027'>
logout<br/>
</a>




<a href='#M000034'>
logout<br/>
</a>




<a href='#M000032'>
new<br/>
</a>




<a href='#M000030'>
query<br/>
</a>




<a href='#M000037'>
query<br/>
</a>




<a href='#M000029'>
retrieve<br/>
</a>




<a href='#M000036'>
retrieve<br/>
</a>


</div>
<div id="spacer"></div><div class="navigation darker index" id="class_wrapper"><div class="list_header"><h3>All classes</h3></div><div class="list_header_link"><a href="#" onclick="toggle('class'); toggleText('class_link'); return false;" id="class_link">Hide...</a></div><div class="clear"></div><div id="class"><form><label for="filter_class">Filter:&nbsp;&nbsp;</label><input type="text" onKeyUp="return filterList('class', this.value, event);" id="filter_class" onKeyPress="return disableSubmit(event);"></input></form></div></div><div class="navigation darker index" id="file_wrapper"><div class="list_header"><h3>All files</h3></div><div class="list_header_link"><a href="#" onclick="toggle('file'); toggleText('file_link'); return false;" id="file_link">Hide...</a></div><div class="clear"></div><div id="file"><form><label for="filter_file">Filter:&nbsp;&nbsp;</label><input type="text" onKeyUp="return filterList('file', this.value, event);" id="filter_file" onKeyPress="return disableSubmit(event);"></input></form></div></div><div class="navigation darker index" id="method_wrapper"><div class="list_header"><h3>All methods</h3></div><div class="list_header_link"><a href="#" onclick="toggle('method'); toggleText('method_link'); return false;" id="method_link">Show...</a></div><div class="clear"></div><div id="method"><form><label for="filter_method">Filter:&nbsp;&nbsp;</label><input type="text" onKeyUp="return filterList('method', this.value, event);" id="filter_method" onKeyPress="return disableSubmit(event);"></input></form></div></div></div><div id="content">
<h1 id="item_name">Class: ProsperAPIClient</h1>

<div id="description"><p>
This class wraps the general purpose stub classes generated by the soap4r
gem from prosper.com&#8216;s WDSL file. Its main purpose is to glue this
application&#8216;s models to the API calls available.
</p>
<p>
As currently implemented, it depends on RAILS_DEFAULT_LOGGER and
ActiveSupport
</p>
</div>




<p></p>


<h1>Constants</h1><p><table><tr><th>Name</th><th>Value</th></tr>
<tr>
<td class="highlight">ALLOWED_PROSPER_OBJECTS</td>

<td class="normal">%w(     Listing Member Bid     Login LoginResponse Logout LogoutResponse     Query QueryResponse     Retrieve RetrieveResponse   ).freeze</td>



</tr>
</table></p>




<h1>Public Class Methods</h1>


<a class="small" name="M000028"><br/></a>
<div class="method_block"><h3>
<a href='#M000028'>


describe

(object_type, auth_token=nil)

</a>
</h3>
<p>
Pass in one of the ALLOWED_PROSPER_OBJECTS to see its list of available
fields from prosper.
</p>

<p class="source_link" id="M000028-show-link"><a href="#" onclick="toggle('M000028-source'); toggleText('M000028-link'); return false;" id="M000028-link">Show source...</a></p><div class="source" id="M000028-source"><pre>    <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 48</span>
48:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe</span>(<span class="ruby-identifier">object_type</span>, <span class="ruby-identifier">auth_token</span>=<span class="ruby-keyword kw">nil</span>)
49:       <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@@api</span>.<span class="ruby-identifier">describe</span>(<span class="ruby-identifier">:authenticationToken</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">auth_token</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">:objectType</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">object_type</span>.<span class="ruby-identifier">to_s</span>)
50:       <span class="ruby-constant">RAILS_DEFAULT_LOGGER</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Describe error: #{response.describeResult.message}&quot;</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">describeResult</span>.<span class="ruby-identifier">success</span>
51:       <span class="ruby-identifier">response</span>.<span class="ruby-identifier">describeResult</span>.<span class="ruby-identifier">definition</span>.<span class="ruby-identifier">fields</span>
52:     <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000031"><br/></a>
<div class="method_block"><h3>
<a href='#M000031'>


fetch_rate_table

()

</a>
</h3>
<p>
Scrape the prosper page containing historical loan rates for each credit
grade for several loan sizes
</p>

<p class="source_link" id="M000031-show-link"><a href="#" onclick="toggle('M000031-source'); toggleText('M000031-link'); return false;" id="M000031-link">Show source...</a></p><div class="source" id="M000031-source"><pre>    <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 73</span>
73:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fetch_rate_table</span>
74:       <span class="ruby-identifier">agent</span> = <span class="ruby-constant">WWW</span><span class="ruby-operator">::</span><span class="ruby-constant">Mechanize</span>.<span class="ruby-identifier">new</span>
75:       <span class="ruby-identifier">page</span> = <span class="ruby-identifier">agent</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'http://www.prosper.com/lend/rates.aspx'</span>)
76:       <span class="ruby-identifier">table</span> = <span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">'table.table_body tr'</span>)
77:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">table</span>.<span class="ruby-identifier">empty?</span>
78:       <span class="ruby-identifier">rate_table</span> = <span class="ruby-identifier">table</span>.<span class="ruby-identifier">inner_text</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/[\t\r\n]/</span>).<span class="ruby-identifier">reject</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:blank?</span>).<span class="ruby-identifier">in_groups_of</span>(<span class="ruby-value">5</span>)
79:       <span class="ruby-identifier">pp</span> <span class="ruby-identifier">headings</span> = [<span class="ruby-identifier">rate_table</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">first</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">rate_table</span>.<span class="ruby-identifier">shift</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>)
80:       <span class="ruby-identifier">pp</span> <span class="ruby-identifier">rates</span> = <span class="ruby-identifier">rate_table</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">row</span>.<span class="ruby-identifier">first</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">row</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>) }
81:       <span class="ruby-identifier">rates</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
82:         <span class="ruby-identifier">row</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">val</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
83:           <span class="ruby-identifier">p</span> [<span class="ruby-identifier">headings</span>[<span class="ruby-identifier">i</span>], <span class="ruby-identifier">val</span>]
84:         <span class="ruby-keyword kw">end</span>
85:       <span class="ruby-keyword kw">end</span>
86:     <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000026"><br/></a>
<div class="method_block"><h3>
<a href='#M000026'>


login

(email, password)

</a>
</h3>
<p>
Sends the credentials to prosper and assigns the auth token from prosper.
Returning nil means <a href="ProsperAPIClient.html#M000026">login</a>
failed.
</p>

<p class="source_link" id="M000026-show-link"><a href="#" onclick="toggle('M000026-source'); toggleText('M000026-link'); return false;" id="M000026-link">Show source...</a></p><div class="source" id="M000026-source"><pre>    <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 31</span>
31:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">login</span>(<span class="ruby-identifier">email</span>, <span class="ruby-identifier">password</span>)
32:       <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@@api</span>.<span class="ruby-identifier">login</span>(<span class="ruby-identifier">:email</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">email</span>, <span class="ruby-identifier">:password</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">password</span>)
33:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">loginResult</span>.<span class="ruby-identifier">success</span>
34:         <span class="ruby-identifier">response</span>.<span class="ruby-identifier">loginResult</span>.<span class="ruby-identifier">message</span>
35:       <span class="ruby-keyword kw">else</span>
36:         <span class="ruby-constant">RAILS_DEFAULT_LOGGER</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Login error: #{response.loginResult.message}&quot;</span>
37:         <span class="ruby-keyword kw">nil</span>
38:       <span class="ruby-keyword kw">end</span>
39:     <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000027"><br/></a>
<div class="method_block"><h3>
<a href='#M000027'>


logout

(auth_token)

</a>
</h3>
<p>
Tells prosper to deauthorize the current token. Always returns success.
</p>

<p class="source_link" id="M000027-show-link"><a href="#" onclick="toggle('M000027-source'); toggleText('M000027-link'); return false;" id="M000027-link">Show source...</a></p><div class="source" id="M000027-source"><pre>    <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 42</span>
42:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logout</span>(<span class="ruby-identifier">auth_token</span>)
43:       <span class="ruby-ivar">@@api</span>.<span class="ruby-identifier">logout</span>(<span class="ruby-identifier">:token</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">auth_token</span>)
44:       <span class="ruby-keyword kw">true</span>
45:     <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000032"><br/></a>
<div class="method_block"><h3>
<a href='#M000032'>


new

(email, password)

</a>
</h3>
<p>
Create a <a href="ProsperAPIClient.html#M000032">new</a> instance of the
API client authorized for a particular user account
</p>

<p class="source_link" id="M000032-show-link"><a href="#" onclick="toggle('M000032-source'); toggleText('M000032-link'); return false;" id="M000032-link">Show source...</a></p><div class="source" id="M000032-source"><pre>     <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 98</span>
 98:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">email</span>, <span class="ruby-identifier">password</span>)
 99:     <span class="ruby-ivar">@email</span>, <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">email</span>, <span class="ruby-identifier">password</span>
100:     <span class="ruby-operator">!</span><span class="ruby-operator">!</span><span class="ruby-identifier">login</span>
101:   <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000030"><br/></a>
<div class="method_block"><h3>
<a href='#M000030'>


query

(object_type, conditions, auth_token=nil, fields=nil)

</a>
</h3>
<p>
Find objects in prosper meeting the given criteria. Gets all fields by
default.
</p>

<p class="source_link" id="M000030-show-link"><a href="#" onclick="toggle('M000030-source'); toggleText('M000030-link'); return false;" id="M000030-link">Show source...</a></p><div class="source" id="M000030-source"><pre>    <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 63</span>
63:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query</span>(<span class="ruby-identifier">object_type</span>, <span class="ruby-identifier">conditions</span>, <span class="ruby-identifier">auth_token</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">fields</span>=<span class="ruby-keyword kw">nil</span>)
64:       <span class="ruby-identifier">fields</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">all_fields</span>(<span class="ruby-identifier">object_type</span>)
65:       <span class="ruby-identifier">conditions</span> = <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">sanitize_sql_for_conditions</span>(<span class="ruby-identifier">conditions</span>)
66:       <span class="ruby-constant">RAILS_DEFAULT_LOGGER</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;#=== ProsperAPIClient#query ===#\n conditions #=&gt; #{conditions}&quot;</span>
67:       <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@@api</span>.<span class="ruby-identifier">query</span>(<span class="ruby-identifier">:authenticationToken</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">auth_token</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">:objectType</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">object_type</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">:fields</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">fields</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>), <span class="ruby-identifier">:conditionExpression</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conditions</span>)
68:       <span class="ruby-constant">RAILS_DEFAULT_LOGGER</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Query error: #{response.queryResult.message}&quot;</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">queryResult</span>.<span class="ruby-identifier">success</span>
69:       <span class="ruby-identifier">response</span>.<span class="ruby-identifier">queryResult</span>.<span class="ruby-identifier">prosperObjects</span>
70:     <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000029"><br/></a>
<div class="method_block"><h3>
<a href='#M000029'>


retrieve

(object_type, keys, auth_token=nil, fields=nil)

</a>
</h3>
<p>
Retrieve a set of objects from prosper identified by their unique keys.
Gets all fields by default.
</p>

<p class="source_link" id="M000029-show-link"><a href="#" onclick="toggle('M000029-source'); toggleText('M000029-link'); return false;" id="M000029-link">Show source...</a></p><div class="source" id="M000029-source"><pre>    <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 55</span>
55:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">object_type</span>, <span class="ruby-identifier">keys</span>, <span class="ruby-identifier">auth_token</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">fields</span>=<span class="ruby-keyword kw">nil</span>)
56:       <span class="ruby-identifier">fields</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">all_fields</span>(<span class="ruby-identifier">object_type</span>)
57:       <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@@api</span>.<span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">:authenticationToken</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">auth_token</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">:objectType</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">object_type</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">:fields</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">fields</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>), <span class="ruby-identifier">:keys</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>)) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">blank?</span>
58:       <span class="ruby-constant">RAILS_DEFAULT_LOGGER</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Retrieve error: #{response.retrieveResult.message}&quot;</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">retrieveResult</span>.<span class="ruby-identifier">success</span>
59:       <span class="ruby-identifier">response</span>.<span class="ruby-identifier">retrieveResult</span>.<span class="ruby-identifier">prosperObjects</span>
60:     <span class="ruby-keyword kw">end</span></pre></div>
</div>


<h1>Public Instance Methods</h1>


<a class="small" name="M000035"><br/></a>
<div class="method_block"><h3>
<a href='#M000035'>


describe

(object_type)

</a>
</h3>
<p>
<a href="Describe.html">Describe</a> the fields available for object_type
from prosper. See <a
href="ProsperAPIClient.html#M000028">ProsperAPIClient#describe</a>.
</p>

<p class="source_link" id="M000035-show-link"><a href="#" onclick="toggle('M000035-source'); toggleText('M000035-link'); return false;" id="M000035-link">Show source...</a></p><div class="source" id="M000035-source"><pre>     <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 114</span>
114:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe</span>(<span class="ruby-identifier">object_type</span>)
115:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">describe</span>(<span class="ruby-identifier">object_type</span>, <span class="ruby-ivar">@auth_token</span>)
116:   <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000033"><br/></a>
<div class="method_block"><h3>
<a href='#M000033'>


login

()

</a>
</h3>
<p>
Log in using the email and password of this instance
</p>

<p class="source_link" id="M000033-show-link"><a href="#" onclick="toggle('M000033-source'); toggleText('M000033-link'); return false;" id="M000033-link">Show source...</a></p><div class="source" id="M000033-source"><pre>     <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 104</span>
104:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">login</span>
105:     <span class="ruby-ivar">@auth_token</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">login</span>(<span class="ruby-ivar">@email</span>, <span class="ruby-ivar">@password</span>)
106:   <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000034"><br/></a>
<div class="method_block"><h3>
<a href='#M000034'>


logout

()

</a>
</h3>
<p>
Deauthorize this instance&#8216;s token
</p>

<p class="source_link" id="M000034-show-link"><a href="#" onclick="toggle('M000034-source'); toggleText('M000034-link'); return false;" id="M000034-link">Show source...</a></p><div class="source" id="M000034-source"><pre>     <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 109</span>
109:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logout</span>
110:     <span class="ruby-ivar">@auth_token</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">logout</span>(<span class="ruby-ivar">@auth_token</span>)
111:   <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000037"><br/></a>
<div class="method_block"><h3>
<a href='#M000037'>


query

(object_type, conditions, fields=nil)

</a>
</h3>
<p>
Find objects in prosper meeting the given criteria. Can <a
href="ProsperAPIClient.html#M000029">retrieve</a> protected fields.
</p>

<p class="source_link" id="M000037-show-link"><a href="#" onclick="toggle('M000037-source'); toggleText('M000037-link'); return false;" id="M000037-link">Show source...</a></p><div class="source" id="M000037-source"><pre>     <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 124</span>
124:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query</span>(<span class="ruby-identifier">object_type</span>, <span class="ruby-identifier">conditions</span>, <span class="ruby-identifier">fields</span>=<span class="ruby-keyword kw">nil</span>)
125:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">query</span>(<span class="ruby-identifier">object_type</span>, <span class="ruby-identifier">conditions</span>, <span class="ruby-ivar">@auth_token</span>, <span class="ruby-identifier">fields</span>)
126:   <span class="ruby-keyword kw">end</span></pre></div>
</div>

<a class="small" name="M000036"><br/></a>
<div class="method_block"><h3>
<a href='#M000036'>


retrieve

(object_type, keys, fields=nil)

</a>
</h3>
<p>
Retrieve a set of objects from prosper identified by their unique keys. Can
<a href="ProsperAPIClient.html#M000029">retrieve</a> protected fields.
</p>

<p class="source_link" id="M000036-show-link"><a href="#" onclick="toggle('M000036-source'); toggleText('M000036-link'); return false;" id="M000036-link">Show source...</a></p><div class="source" id="M000036-source"><pre>     <span class="ruby-comment cmt"># File app/models/prosper_api_client.rb, line 119</span>
119:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">object_type</span>, <span class="ruby-identifier">keys</span>, <span class="ruby-identifier">fields</span>=<span class="ruby-keyword kw">nil</span>)
120:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">object_type</span>, <span class="ruby-identifier">keys</span>, <span class="ruby-ivar">@auth_token</span>, <span class="ruby-identifier">fields</span>)
121:   <span class="ruby-keyword kw">end</span></pre></div>
</div>





</div><div class="clear" id="footer">Generated on May 14, 2008 / Allison 2 &copy; 2007 <a href="http://cloudbur.st">Cloudburst, LLC</a></div></div></body></html>